//
//  URLResponse.m
//  BaoZhangWang
//
//  Created by 叶越悦 on 15/10/14.
//  Copyright © 2015年 BaoliNetworkTechnology. All rights reserved.
//

#import "URLResponse.h"

@interface URLResponse ()

@property (nonatomic, strong, readwrite) id responseObject;
@property (nonatomic, strong, readwrite) NSURLRequest *request;
@property (nonatomic, readwrite) NSInteger requestId;
@property (nonatomic, strong, readwrite) NSError *error;
@property (nonatomic, strong, readwrite) NSURLResponse *response;
@property (nonatomic, strong, readwrite) NSDictionary *responseHeader;
@property (nonatomic, readwrite) NSInteger requestIdentifier;

@end

@implementation URLResponse

- (void)setResponse:(NSURLResponse *)response {
    _response = response;
    if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
        _responseHeader = [httpResponse.allHeaderFields copy];
    }
}

- (URLResponseStatus)status {
    return self.error ? URLResponseStatusErrorHttpError : URLResponseStatusSuccess;
}
@end
